module sw.locale.locale;
import std.stdio, std.string;

///現地化の構造体
struct Locale{
  static enum Menu{
    index = 0,
    menu,
    _new,
    list,
    recent,
    help,
    login,
    setting,
    show,
    source,
    edit,
    diff,
    reCreate,
    backuplist,
    freeze,
    unfreeze,
    cancel,
  };
  static enum About{
    generated = Menu.max+1,
    license,
  };
  static enum Parser{
    errorArgs = About.max+1,
    errorSecurity,
  };
  static enum Page{
    edit = Parser.max+1,
    editDescription,
    conflict,
    conflictDescription,
    conflictDiff,
    write,
    _delete,
    unsupported,
    unsupportedDescription,
    backuplist,
    backuplistDiff,
    backuplistDeleteprevious,
    backup,
    backupdiff,
    deleteprevious,
    deletepreviousSuccess,
    source,
    freeze,
    freezeAlready,
    freezeSuccess,
    unfreeze,
    unfreezeYet,
    unfreezeSuccess,
    diff,
    diffNodiff,
    _new,
    newLabel,
    preview,
    list,
    recent,
    help,
    login,
    loginLabel,
    loginValue,
    loginFailed,
    loginFailedDescription,
    logined,
    loginedDescription,
    info,
    infoName,
    infoVersion,
    infoCreator,
    infoContributor,
    infoLicense,
    infoDLangSpecificationVersion,
    infoCompiler,
    infoBuildType,
    infoEnableOptions,
    infoDatetime,
    infoNone,
  };
  static enum EnumLength = Page.max+1;
}

///文字列からメニューのIDを取得
///Bugs: prefixと処理を分離すべき
Locale.Menu getMenuLocaleId(string str){
  switch(str){
    case "wiki:index":
      return Locale.Menu.index;
    case "wiki:menu":
      return Locale.Menu.menu;
    case "wiki:new":
      return Locale.Menu._new;
    case "wiki:list":
      return Locale.Menu.list;
    case "wiki:recent":
      return Locale.Menu.recent;
    case "wiki:help":
      return Locale.Menu.help;
    case "admin:login":
      return Locale.Menu.login;
    case "admin:setting":
      return Locale.Menu.setting;
    case "wiki:show":
      return Locale.Menu.show;
    case "wiki:source":
      return Locale.Menu.source;
    case "wiki:edit":
      return Locale.Menu.edit;
    case "wiki:diff":
      return Locale.Menu.diff;
    case "wiki:re-create":
      return Locale.Menu.reCreate;
    case "wiki:backuplist":
      return Locale.Menu.backuplist;
    case "wiki:freeze":
      return Locale.Menu.freeze;
    case "wiki:unfreeze":
      return Locale.Menu.unfreeze;
    default:
  }
  assert(0, "Unknown Identifier: "~str);
}
